import { HttpStatus } from "./http-status.enum";

export class HttpException extends Error {
  private readonly res: string | Object;
  private readonly status: HttpStatus;
  constructor(res: string | Object, status: HttpStatus) {
    super();
    this.res = res;
    this.status = status;
  }
  getResponse() {
    return this.res;
  }
  getStatus() {
    return this.status;
  }
}
export class BadRequestException extends HttpException {
  constructor(message, error?) {
    super(
      {
        message,
        error,
        statusCode: HttpStatus.BAD_REQUEST,
      },
      HttpStatus.BAD_REQUEST
    );
  }
}
export class ForbiddenException extends HttpException {
  constructor(message, error?) {
    super(
      {
        message,
        error,
        statusCode: HttpStatus.FORBIDDEN,
      },
      HttpStatus.FORBIDDEN
    );
  }
}
export class BadGateWayException extends HttpException {
  constructor(message, error?) {
    super(
      {
        message,
        error,
        statusCode: HttpStatus.BAD_GATEWAY,
      },
      HttpStatus.BAD_GATEWAY
    );
  }
}
export class RequestTimeoutException extends HttpException {
  constructor(message, error?) {
    super(
      {
        message,
        error,
        statusCode: HttpStatus.REQUEST_TIMEOUT,
      },
      HttpStatus.REQUEST_TIMEOUT
    );
  }
}
